/*
 * Copyright 2012 Alan Burlison, alan@bleaklow.com.  All rights reserved.
 * Use is subject to license terms.  See LICENSE.txt for details.
 */

/*
 * port_t initialisers for Arduino pin numberings.
 */

#ifndef arduino_pins_h
#define arduino_pins_h

#include "utils.h"

// Duemilanove.
#if defined(__AVR_ATmega328P__)

#define ARD_D0  INIT_PIN(D, 0)
#define ARD_D1  INIT_PIN(D, 1)
#define ARD_D2  INIT_PIN(D, 2)
#define ARD_D3  INIT_PIN(D, 3)
#define ARD_D4  INIT_PIN(D, 4)
#define ARD_D5  INIT_PIN(D, 5)
#define ARD_D6  INIT_PIN(D, 6)
#define ARD_D7  INIT_PIN(D, 7)
#define ARD_D8  INIT_PIN(B, 0)
#define ARD_D9  INIT_PIN(B, 1)
#define ARD_D10 INIT_PIN(B, 2)
#define ARD_D11 INIT_PIN(B, 3)
#define ARD_D12 INIT_PIN(B, 4)
#define ARD_D13 INIT_PIN(B, 5)
#define ARD_D14 INIT_PIN(C, 0)
#define ARD_D15 INIT_PIN(C, 1)
#define ARD_D16 INIT_PIN(C, 2)
#define ARD_D17 INIT_PIN(C, 3)
#define ARD_D18 INIT_PIN(C, 4)
#define ARD_D19 INIT_PIN(C, 5)
#define ARD_A0  ARD_D14
#define ARD_A1  ARD_D15
#define ARD_A2  ARD_D16
#define ARD_A3  ARD_D17
#define ARD_A4  ARD_D18
#define ARD_A5  ARD_D19

// Mega.
#elif defined(__AVR_ATmega1280__)

#define ARD_D0  INIT_PIN(E, 0)
#define ARD_D1  INIT_PIN(E, 1)
#define ARD_D2  INIT_PIN(E, 4)
#define ARD_D3  INIT_PIN(E, 5)
#define ARD_D4  INIT_PIN(G, 5)
#define ARD_D5  INIT_PIN(E, 3)
#define ARD_D6  INIT_PIN(H, 3)
#define ARD_D7  INIT_PIN(H, 4)
#define ARD_D8  INIT_PIN(H, 5)
#define ARD_D9  INIT_PIN(H, 6)
#define ARD_D10 INIT_PIN(B, 4)
#define ARD_D11 INIT_PIN(B, 5)
#define ARD_D12 INIT_PIN(B, 6)
#define ARD_D13 INIT_PIN(B, 7)
#define ARD_D14 INIT_PIN(J, 1)
#define ARD_D15 INIT_PIN(J, 0)
#define ARD_D16 INIT_PIN(H, 1)
#define ARD_D17 INIT_PIN(H, 0)
#define ARD_D18 INIT_PIN(D, 3)
#define ARD_D19 INIT_PIN(D, 2)
#define ARD_D20 INIT_PIN(D, 1)
#define ARD_D21 INIT_PIN(D, 0)
#define ARD_D22 INIT_PIN(A, 0)
#define ARD_D23 INIT_PIN(A, 1)
#define ARD_D24 INIT_PIN(A, 2)
#define ARD_D25 INIT_PIN(A, 3)
#define ARD_D26 INIT_PIN(A, 4)
#define ARD_D27 INIT_PIN(A, 5)
#define ARD_D28 INIT_PIN(A, 6)
#define ARD_D29 INIT_PIN(A, 7)
#define ARD_D30 INIT_PIN(C, 7)
#define ARD_D31 INIT_PIN(C, 6)
#define ARD_D32 INIT_PIN(C, 5)
#define ARD_D33 INIT_PIN(C, 4)
#define ARD_D34 INIT_PIN(C, 3)
#define ARD_D35 INIT_PIN(C, 2)
#define ARD_D36 INIT_PIN(C, 1)
#define ARD_D37 INIT_PIN(C, 0)
#define ARD_D38 INIT_PIN(D, 7)
#define ARD_D39 INIT_PIN(G, 2)
#define ARD_D40 INIT_PIN(G, 1)
#define ARD_D41 INIT_PIN(G, 0)
#define ARD_D42 INIT_PIN(L, 7)
#define ARD_D43 INIT_PIN(L, 6)
#define ARD_D44 INIT_PIN(L, 5)
#define ARD_D45 INIT_PIN(L, 4)
#define ARD_D46 INIT_PIN(L, 3)
#define ARD_D47 INIT_PIN(L, 2)
#define ARD_D48 INIT_PIN(L, 1)
#define ARD_D49 INIT_PIN(L, 0)
#define ARD_D50 INIT_PIN(B, 3)
#define ARD_D51 INIT_PIN(B, 2)
#define ARD_D52 INIT_PIN(B, 1)
#define ARD_D53 INIT_PIN(B, 0)
#define ARD_D54 INIT_PIN(F, 0)
#define ARD_D55 INIT_PIN(F, 1)
#define ARD_D56 INIT_PIN(F, 2)
#define ARD_D57 INIT_PIN(F, 3)
#define ARD_D58 INIT_PIN(F, 4)
#define ARD_D59 INIT_PIN(F, 5)
#define ARD_D60 INIT_PIN(F, 6)
#define ARD_D61 INIT_PIN(F, 7)
#define ARD_D62 INIT_PIN(K, 0)
#define ARD_D63 INIT_PIN(K, 1)
#define ARD_D64 INIT_PIN(K, 2)
#define ARD_D65 INIT_PIN(K, 3)
#define ARD_D66 INIT_PIN(K, 4)
#define ARD_D67 INIT_PIN(K, 5)
#define ARD_D68 INIT_PIN(K, 6)
#define ARD_D69 INIT_PIN(K, 7)
#define ARD_D70 INIT_PIN(H, 2)
#define ARD_D71 INIT_PIN(H, 7)
#define ARD_D72 INIT_PIN(J, 2)
#define ARD_D73 INIT_PIN(J, 3)
#define ARD_D74 INIT_PIN(J, 4)
#define ARD_D75 INIT_PIN(J, 5)
#define ARD_D76 INIT_PIN(J, 6)
#define ARD_D77 INIT_PIN(J, 7)
#define ARD_A0  ARD_D54
#define ARD_A1  ARD_D55
#define ARD_A2  ARD_D56
#define ARD_A3  ARD_D57
#define ARD_A4  ARD_D58
#define ARD_A5  ARD_D59
#define ARD_A6  ARD_D60
#define ARD_A7  ARD_D61
#define ARD_A8  ARD_D62
#define ARD_A9  ARD_D63
#define ARD_A10 ARD_D64
#define ARD_A11 ARD_D65
#define ARD_A12 ARD_D66
#define ARD_A13 ARD_D67
#define ARD_A14 ARD_D68
#define ARD_A15 ARD_D69

// Otherwise, unknown.
#else
#error "Unknown MCU type"
#endif

#endif /* arduino_pins_h */
